<% slot = slot || (piece.new_record? ? nil : piece.slot) %>

<% if slot && !slot.new_record? %>
  <% form_url = Rails.application.routes.url_helpers.vitrage_piece_path(slot.id) %>
  <% form_method = :patch %>
<% else %>
  <% form_url = Rails.application.routes.url_helpers.vitrage_pieces_path %>
  <% form_method = :post %>
<% end %>

<%#TODO make helper for building forms in the piece partial (like the `form` method of active_admin) %>
<%= render partial: "vitrage/#{piece.class.name.demodulize.underscore}_form", locals: { piece: piece, form_url: form_url, form_method: form_method } %>
